package cards;

import model.Player;
import fields.Ownable;
import fields.Street;

public class ConditionedPay extends Pay {
	private int hotelAmount;
	
	public ConditionedPay(String text, int amount, int hotelAmount) {
		super(text, amount);
		this.hotelAmount = hotelAmount;
	}

	@Override
	public void execute(Player player){
		int total = 0;
		for(Ownable o : player.getOwned()){
			if(o != null && o instanceof Street){
				Street s = (Street)o;
				if(s.getHouseCount() == 5){
					total += this.hotelAmount;
				}else{
					total += s.getHouseCount() * this.amount;
				}
			}
		}
		if(total > 0){
			player.withdraw(total);
		}
	}
}